package design.ObserverPattern;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by looper on 2017/8/19.
 */
public class ConcreteSubject implements Subject{
  private List<Observer> weixinList = new ArrayList<>();

  public ConcreteSubject(){
    weixinList.clear();
  }

  @Override
  public void add(Observer observer) {
    weixinList.add(observer);
  }

  @Override
  public void delete(Observer observer) {
    weixinList.remove(observer);
  }

  @Override
  public void notifyUser(String information) {
    for (Observer observer: weixinList) {
      observer.show(information);
    }
  }
}
